/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaColorPalette.h"

#define CObjPtr ((CColorPaletteUI*)m_cobj)

namespace DuiLib {

DWORD LuaColorPalette::GetSelectColor()
{
    return CObjPtr->GetSelectColor();
}

void LuaColorPalette::SetSelectColor(DWORD dwColor)
{
    CObjPtr->SetSelectColor(dwColor);
}

void LuaColorPalette::SetPalletHeight(int nHeight)
{
    CObjPtr->SetPalletHeight(nHeight);
}

int	LuaColorPalette::GetPalletHeight()
{
    return CObjPtr->GetPalletHeight();
}

void LuaColorPalette::SetBarHeight(int nHeight)
{
    CObjPtr->SetBarHeight(nHeight);
}

int LuaColorPalette::GetBarHeight()
{
    return CObjPtr->GetBarHeight();
}

int LuaColorPalette::GetThumbImage(LuaState *L)
{
    SDTString str = CObjPtr->GetThumbImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaColorPalette::SetThumbImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetThumbImage(str.c_str());
    return 0;
}

int LuaColorPalette::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

SDLUA_BEGIN_REGISTER(LuaColorPalette, ColorPalette, Control)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, GetSelectColor, GetSelectColor)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, SetSelectColor, SetSelectColor)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, SetPalletHeight, SetPalletHeight)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, GetPalletHeight, GetPalletHeight)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, SetBarHeight, SetBarHeight)
    SDLUA_REGISTER_FUN_CPP(LuaColorPalette, GetBarHeight, GetBarHeight)

    SDLUA_REGISTER_FUN_LUA(LuaColorPalette, SetThumbImage, SetThumbImage)
    SDLUA_REGISTER_FUN_LUA(LuaColorPalette, GetThumbImage, GetThumbImage)
    SDLUA_REGISTER_FUN_LUA(LuaColorPalette, SetPos, SetPos)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaColorPalette, ColorPalette)
SDLUA_END_UNREGISTER(ColorPalette)

}

#undef CObjPtr